package util;

import java.io.File;

/**
 * 路径工具类
 * @author kaizen
 *
 */
public class PathUitls {


	/**
	 * 	获取当前线程的类路径
	 * @return
	 */
	public static String getClasspath()
	  {
	    String path = (String.valueOf(Thread.currentThread().getContextClassLoader().getResource("")))
				.replaceAll("file:/", "").replaceAll("%20", " ").trim();
	    if (path.indexOf(":") != 1) {
	      path = File.separator + path;
	    }
	    return path;
	  }

	/**
	 * 获取项目路径 （用户目录）
	 * @return
	 */
	public static String getProjectPath()
	  {
	    String nowpath = "";
	    nowpath = System.getProperty("user.dir") + "/";
	    return nowpath;
	  }

	/**
	 * 获取SystemResource下的文件
	 * @param fileName
	 * @return
	 */
	public static String getFilePathOfResource(String fileName)
	  {
	    String nowpath = "";
	    nowpath = ClassLoader.getSystemResource(fileName).toString().replaceAll("file:/", "");
	    return nowpath;
	  }
	  
	 
	  public static void main(String[] args) {
			System.out.println( PathUitls.getFilePathOfResource("jdbc.properties"));//D:/eclipse_workspace/test/target/classes/jdbc.properties
	    	//String jdbcPropertiesPath = PathUitl.getClasspath()+PropertyUtil.getPro(path, "jdbc.url");

		}
	  
}
